package electrycity;

import org.apache.hadoop.fs.FSDataOutputStream;
import org.apache.hadoop.fs.FileSystem;
import org.apache.hadoop.fs.Path;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.RecordWriter;
import org.apache.hadoop.mapreduce.TaskAttemptContext;
import org.apache.hadoop.mapreduce.lib.output.FileOutputFormat;

import java.io.IOException;

public class MyOutputFormat extends FileOutputFormat {
    @Override
    public RecordWriter<Text, ElectricWritable> getRecordWriter(TaskAttemptContext job) throws IOException, InterruptedException {
        FileSystem fs = FileSystem.get(job.getConfiguration());
        FSDataOutputStream qsOutputStream = fs.create(new Path("file/electricity/out/qs"));
        FSDataOutputStream wzOutputStream = fs.create(new Path("file/electricity/out/wz"));
        return new MyRecordWriter(qsOutputStream, wzOutputStream);
    }
}
